* Vote variables

* Voting left in country-year when an election has taken place or is close enough

gen vleft = .
replace vleft = 1 if prtvtat == 1 & year==2002 // Austria SPO
replace vleft = 0 if (prtvtat ~= 1 & prtvtat ~= . & year==2002 & cntry=="AT")
replace vleft = 1 if prtvtaat == 1 & year==2006 // Austria SPO
replace vleft = 0 if (prtvtaat ~= 1 & prtvtaat ~= . & year==2006 & cntry=="AT")

replace vleft = 1 if (prtvtabe == 5 | prtvtabe == 13) & year==2004 // Belgium PS/SP.A-Spirit
replace vleft = 0 if (prtvtabe ~= 5 & prtvtabe ~= 13 & prtvtabe ~= . & year==2004 & cntry=="BE")
replace vleft = 1 if (prtvtbbe == 5 | prtvtbbe == 13) & year==2008 // Belgium PS/SP.A. + Vlaams - Progressieven (Spirit)
replace vleft = 0 if (prtvtbbe ~= 5 & prtvtbbe ~= 13 & prtvtbbe ~= . & year==2008 & cntry=="BE")
replace vleft = 1 if (prtvtcbe == 5 | prtvtcbe == 13) & year==2010 // Belgium PS/SP.A.
replace vleft = 0 if (prtvtcbe ~= 5 & prtvtcbe ~= 13 & prtvtcbe ~= . & year==2010 & cntry=="BE")

replace vleft = 1 if prtvtdk == 1 & year==2002 // Denmark Socialdemokraterne
replace vleft = 0 if (prtvtdk ~= 1 & prtvtdk ~= . & year==2002 & cntry=="DK")
replace vleft = 1 if prtvtadk == 1 & year==2006 // Denmark Socialdemokraterne
replace vleft = 0 if (prtvtadk ~= 1 & prtvtadk ~= . & year==2006 & cntry=="DK")
replace vleft = 1 if prtvtbdk == 1 & year==2008 // Denmark Socialdemokraterne
replace vleft = 0 if (prtvtbdk ~= 1 & prtvtbdk ~= . & year==2008 & cntry=="DK")
replace vleft = 1 if prtvtcdk == 1 & year==2012 // Denmark Socialdemokraterne
replace vleft = 0 if (prtvtcdk ~= 1 & prtvtcdk ~= . & year==2012 & cntry=="DK")

replace vleft = 1 if prtvde2 == 1 & year==2002 // Germany SPD
replace vleft = 0 if (prtvde2 ~= 1 & prtvde2 ~= . & year==2002 & cntry=="DE")
replace vleft = 1 if prtvbde2 == 1 & year==2006 // Germany SPD
replace vleft = 0 if (prtvbde2 ~= 1 & prtvbde2 ~= . & year==2006 & cntry=="DE")
replace vleft = 1 if prtvcde1 == 1 & year==2010 // Germany SPD
replace vleft = 0 if (prtvcde1 ~= 1 & prtvcde1 ~= . & year==2010 & cntry=="DE")

replace vleft = 1 if prtvtaes == 2 & year==2004 // Spain PSOE
replace vleft = 0 if (prtvtaes ~= 2 & prtvtaes ~= . & year==2004 & cntry=="ES")
replace vleft = 1 if prtvtbes == 2 & year==2008 // Spain PSOE
replace vleft = 0 if (prtvtbes ~= 2 & prtvtbes ~= . & year==2008 & cntry=="ES")
replace vleft = 1 if prtvtces == 2 & year==2012 // Spain PSOE
replace vleft = 0 if (prtvtces ~= 2 & prtvtces ~= . & year==2012 & cntry=="ES")

replace vleft = 1 if prtvtfi == 9 & year==2004 // Finland Finnish Social Democratic Party 
replace vleft = 0 if (prtvtfi ~= 9 & prtvtfi ~= . & year==2004 & cntry=="FI")
replace vleft = 1 if prtvtafi == 8 & year==2008 // Finland Finnish Social Democratic Party 
replace vleft = 0 if (prtvtafi ~= 8 & prtvtafi ~= . & year==2008 & cntry=="FI")
replace vleft = 1 if prtvtcfi == 13 & year==2012 // Finland Social Democratic Party 
replace vleft = 0 if (prtvtcfi ~= 13 & prtvtcfi ~= . & year==2012 & cntry=="FI")

replace vleft = 1 if prtvtfr == 10 & year==2002 // France SPD
replace vleft = 0 if (prtvtfr ~= 10 & prtvtfr ~= . & year==2002 & cntry=="FR")
replace vleft = 1 if prtvtbfr == 8 & year==2008 // France SPD
replace vleft = 0 if (prtvtbfr ~= 8 & prtvtbfr ~= . & year==2008 & cntry=="FR")
replace vleft = 1 if prtvtcfr == 9 & year==2012 // France SPD
replace vleft = 0 if (prtvtcfr ~= 9 & prtvtcfr ~= . & year==2012 & cntry=="FR")

replace vleft = 1 if prtvtgb == 2 & year==2002 // GB Labour
replace vleft = 0 if (prtvtgb ~= 2 & prtvtgb ~= . & year==2002 & cntry=="GB")
replace vleft = 1 if prtvtagb == 2 & year==2006 // GB Labour
replace vleft = 0 if (prtvtagb ~= 2 & prtvtagb ~= . & year==2006 & cntry=="GB")
replace vleft = 1 if prtvtgb == 2 & year==2010 // GB Labour
replace vleft = 0 if (prtvtgb ~= 2 & prtvtgb ~= . & year==2010 & cntry=="GB")

replace vleft = 1 if prtvtagr == 1 & year==2004 // Greece PASOK
replace vleft = 0 if (prtvtagr ~= 1 & prtvtagr ~= . & year==2004 & cntry=="GR")
* Greek election 4 October 2009, ESS survey dates 15.07.09 – 20.11.09
* replace vleft = 1 if prtvtbgr == 1 & year==2008 // Greece PASOK
* replace vleft = 0 if (prtvtbgr ~= 1 & prtvtbgr ~= . & year==2008 & cntry=="GR")
replace vleft = 1 if prtvtcgr == 1 & year==2010 // Greece PASOK
replace vleft = 0 if (prtvtcgr ~= 1 & prtvtcgr ~= . & year==2010 & cntry=="GR")

replace vleft = 1 if prtvtie == 3 & year==2002 // Ireland Labour
replace vleft = 0 if (prtvtie ~= 3 & prtvtie ~= . & year==2002 & cntry=="IE")
replace vleft = 1 if prtvtie == 3 & year==2008 // Ireland Labour
replace vleft = 0 if (prtvtie ~= 3 & prtvtie ~= . & year==2008 & cntry=="IE")
replace vleft = 1 if prtvtaie == 5 & year==2012 // Ireland Labour
replace vleft = 0 if (prtvtaie ~= 5 & prtvtaie ~= . & year==2012 & cntry=="IE")

replace vleft = 1 if prtvtnl == 2 & year==2002 // Netherlands PvdA
replace vleft = 0 if (prtvtnl ~= 2 & prtvtnl ~= . & year==2002 & cntry=="NL")
replace vleft = 1 if prtvtanl == 2 & year==2004 // Netherlands PvdA
replace vleft = 0 if (prtvtanl ~= 2 & prtvtanl ~= . & year==2004 & cntry=="NL")
replace vleft = 1 if prtvtdnl == 2 & year==2010 // Netherlands PvdA
replace vleft = 0 if (prtvtdnl ~= 2 & prtvtdnl ~= . & year==2010 & cntry=="NL")

replace vleft = 1 if prtvtno == 3 & year==2002 // Norway Labour Party (A)
replace vleft = 0 if (prtvtno ~= 3 & prtvtno ~= . & year==2002 & cntry=="NO")
replace vleft = 1 if prtvtno == 3 & year==2006 // Norway Labour Party (A)
replace vleft = 0 if (prtvtno ~= 3 & prtvtno ~= . & year==2006 & cntry=="NO")
replace vleft = 1 if prtvtano == 3 & year==2010 // Norway Labour Party (A)
replace vleft = 0 if (prtvtano ~= 3 & prtvtano ~= . & year==2010 & cntry=="NO")

replace vleft = 1 if prtvtpt == 10 & year==2002 // Portugal PS - Partido Socialista
replace vleft = 0 if (prtvtpt ~= 10 & prtvtpt ~= . & year==2002 & cntry=="PT")
replace vleft = 1 if prtvtapt == 11 & year==2006 // Portugal PS - Partido Socialista
replace vleft = 0 if (prtvtapt ~= 11 & prtvtapt ~= . & year==2006 & cntry=="PT")
replace vleft = 1 if prtvtbpt == 11 & year==2010 // Portugal PS - Partido Socialista
replace vleft = 0 if (prtvtbpt ~= 11 & prtvtbpt ~= . & year==2010 & cntry=="PT")
replace vleft = 1 if prtvtbpt == 11 & year==2012 // Portugal PS - Partido Socialista
replace vleft = 0 if (prtvtbpt ~= 11 & prtvtbpt ~= . & year==2012 & cntry=="PT")

replace vleft = 1 if prtvtse == 6 & year==2002 // Sweden Social Democrats
replace vleft = 0 if (prtvtse ~= 6 & prtvtse ~= . & year==2002 & cntry=="SE")
replace vleft = 1 if prtvtse == 6 & year==2006 // Sweden Social Democrats
replace vleft = 0 if (prtvtse ~= 6 & prtvtse ~= . & year==2006 & cntry=="SE")
replace vleft = 1 if prtvtase == 6 & year==2010 // Sweden Social Democrats
replace vleft = 0 if (prtvtase ~= 6 & prtvtase ~= . & year==2010 & cntry=="SE")


* Voting populist right
* Not included if less tha 1.5% of the ESS survey
* This means not having observations in Germany (3 elections and ESS waves)
* and Finland (election in 2003 and ESS 2004 wave)
* Greece clears the threshold (just).

gen vpopright = .
replace vpopright = 1 if prtvtat == 3 & year==2002 // Austria FPO
replace vpopright = 0 if (prtvtat ~= 3 & prtvtat ~= . & year==2002 & cntry=="AT")
replace vpopright = 1 if (prtvtaat == 3 | prtvtaat == 4) & year==2006 // Austria FPO or BZO
replace vpopright = 0 if (prtvtaat ~= 3 & prtvtaat ~= 4 & prtvtaat ~= . & year==2006 & cntry=="AT")

replace vpopright = 1 if (prtvtabe == 7 | prtvtabe == 11) & year==2004 // Belgium Vlaams Blok or Front National
replace vpopright = 0 if (prtvtabe ~= 7 & prtvtabe ~= 11 & prtvtabe ~= . & year==2004 & cntry=="BE")
replace vpopright = 1 if (prtvtbbe == 7 | prtvtbbe == 11) & year==2008 // Belgium Vlaams Belang or Front National
replace vpopright = 0 if (prtvtbbe ~= 7 & prtvtbbe ~= 11 & prtvtbbe ~= . & year==2008 & cntry=="BE")
replace vpopright = 1 if (prtvtcbe == 7 | prtvtcbe == 11) & year==2010 // Belgium Vlaams Belang or Front National
replace vpopright = 0 if (prtvtcbe ~= 7 & prtvtcbe ~= 11 & prtvtcbe ~= . & year==2010 & cntry=="BE")

replace vpopright = 1 if (prtvtdk == 6 | prtvtdk == 9) & year==2002 // Denmark Dansk Folkeparti or Fremskridtspartiet
replace vpopright = 0 if (prtvtdk ~= 6 & prtvtdk ~= 9 & prtvtdk ~= . & year==2002 & cntry=="DK")
replace vpopright = 1 if (prtvtadk == 6 | prtvtadk == 9) & year==2006 // Denmark Dansk Folkeparti or Fremskridtspartiet
replace vpopright = 0 if (prtvtadk ~= 6 & prtvtadk ~= 9 & prtvtadk ~= . & year==2006 & cntry=="DK")
replace vpopright = 1 if prtvtbdk == 5 & year==2008 // Denmark Dansk Folkeparti
replace vpopright = 0 if (prtvtbdk ~= 5 & prtvtbdk ~= . & year==2008 & cntry=="DK")
replace vpopright = 1 if prtvtcdk == 5 & year==2012 // Denmark Dansk Folkeparti
replace vpopright = 0 if (prtvtcdk ~= 5 & prtvtcdk ~= . & year==2012 & cntry=="DK")

replace vpopright = 1 if prtvtafi == 5 & year==2008 // Finland True Finns 
replace vpopright = 0 if (prtvtafi ~= 5 & prtvtafi ~= . & year==2008 & cntry=="FI")
replace vpopright = 1 if prtvtcfi == 4 & year==2012 // Finland True Finns 
replace vpopright = 0 if (prtvtcfi ~= 4 & prtvtcfi ~= . & year==2012 & cntry=="FI")

replace vpopright = 1 if (prtvtfr == 3 | prtvtfr == 7 | prtvtfr == 8) & year==2002 // France Front National or Mouvement 
// National Republicain or Mouvement pour la France
replace vpopright = 0 if (prtvtfr ~= 3 & prtvtfr ~= 7 & prtvtfr ~= 8 & prtvtfr ~= . & year==2002 & cntry=="FR")
replace vpopright = 1 if (prtvtbfr == 2 | prtvtbfr == 5) & year==2008 // France Front National or Mouvement pour la France
replace vpopright = 0 if (prtvtbfr ~= 2 & prtvtbfr ~= 5 & prtvtbfr ~= . & year==2008 & cntry=="FR")
replace vpopright = 1 if (prtvtcfr == 2 | prtvtcfr == 8) & year==2012 // France Front National or Mouvement pour la France
replace vpopright = 0 if (prtvtcfr ~= 2 & prtvtcfr ~= 8 & prtvtcfr ~= . & year==2012 & cntry=="FR")

replace vpopright = 1 if prtvtagr == 6 & year==2004 // Greece LAOS
replace vpopright = 0 if (prtvtagr ~= 6 & prtvtagr ~= . & year==2004 & cntry=="GR")
* Greek election 4 October 2009, ESS survey dates 15.07.09 – 20.11.09
* replace vpopright = 1 if prtvtbgr == 5 & year==2008 // Greece LAOS
* replace vpopright = 0 if (prtvtbgr ~= 5 & prtvtbgr ~= . & year==2008 & cntry=="GR")
replace vpopright = 1 if prtvtcgr == 4 & year==2010 // Greece LAOS
replace vpopright = 0 if (prtvtcgr ~= 4 & prtvtcgr ~= . & year==2010 & cntry=="GR")

replace vpopright = 1 if prtvtnl == 4 & year==2002 // Netherlands List Pim Fortuyn
replace vpopright = 0 if (prtvtnl ~= 4 & prtvtnl ~= . & year==2002 & cntry=="NL")
replace vpopright = 1 if prtvtanl == 4 & year==2004 // Netherlands List Pim Fortuyn
replace vpopright = 0 if (prtvtanl ~= 4 & prtvtanl ~= . & year==2004 & cntry=="NL")
replace vpopright = 1 if (prtvtdnl == 3 | prtvtdnl == 11) & year==2010 // Netherlands PVV (List Wilders) or TON (List Verdonk) 
replace vpopright = 0 if (prtvtdnl ~= 3 & prtvtdnl ~= 11 & prtvtdnl ~= . & year==2010 & cntry=="NL")

replace vpopright = 1 if prtvtno == 8 & year==2002 // Norway Progress Party (FrP)
replace vpopright = 0 if (prtvtno ~= 8 & prtvtno ~= . & year==2002 & cntry=="NO")
replace vpopright = 1 if prtvtno == 8 & year==2006 // Norway Progress Party (FrP)
replace vpopright = 0 if (prtvtno ~= 8 & prtvtno ~= . & year==2006 & cntry=="NO")
replace vpopright = 1 if prtvtano == 8 & year==2010 // Norway Progress Party (FrP)
replace vpopright = 0 if (prtvtano ~= 8 & prtvtano ~= . & year==2010 & cntry=="NO")




